
var winClientes = 0;

function abrirProcurarClientes(todos) {
	if(winClientes) {
		if(!winClientes.closed) {
			winClientes.close();
		}
	}
	winClientes = window.open("common.procurar-cliente?mostrar="+(todos?"todos":"activos"), "winClientes", "menubar=no, height=295, width=335, resizable=no");
	winClientes.focus();
}

function openLocalFolder(reference, networkID) {
	if(networkID == "null") {
		alert("Nao e possivel abrir a pasta.");
	}
	else {
		if(navigator.appVersion.indexOf("Mac") != -1) {
			path = "file:///Users/Elsa/Desktop/Ficheiros/"+reference+"/";
			alert(path);
			window.open(path, "pasta_mac");
		}
		else {
			window.open("file://"+networkID+"\\"+reference, "_blank", "");
		}
	}
}

function openServerFolder(reference) {
	var array = reference.split("-");
	var ano = array[0];
	var mes = array[1];
	if(navigator.appVersion.indexOf("Mac") != -1) {
		//document.location = "file:///Network/WORKGROUP/SERVIDORDADOS/ROOT/Ficheiros/"+reference;
		document.location = "file:///Volumes/WORKGROUP\\;SERVIDORDADOS/ROOT/"+reference;
	}
	else {
		window.open("file://\\\\servidordados\\ROOT\\Ficheiros\\20"+ano+"\\"+mes+"\\"+reference, "_blank");
	}
}

function seleccionarTamanho(tipo) {
	if(tipo == "o") {
		document.form1.tamanho_a.value = "";
		document.form1.tamanho_r.value = "";
	}
	else if(tipo == "a") {
		document.form1.tamanho_r.value = "";
	}
	else if(tipo == "r") {
		document.form1.tamanho_a.value = "";
	}
	else {
		alert("erro! tipo: "+tipo);
	}
}


function abrirCalendario(element) {
	alert("Nao implementado!");
}

function isReference(str) {
	if(str.length != 10) {
		return false;
	}
	else {
		var array = str.split("-");
		if(array.length != 3) {
			array = str.split(" ");
			if(array.length != 3) {
				return false;
			}
		}
		if(!isDate("20"+array[0]+"-"+array[1]+"-01")) {
			return false;
		}
		if(array[2].length != 4) {
			return false;
		}
		return true;
	}
}

function isMeasure(str) {
	var array = str.split("x");
	if(array.length != 2) {
		array = str.split("X");
		if(array.length != 2) {
			return false;
		}
	}
	var m1 = Strings.trim(array[0]);
	var m2 = Strings.trim(array[1]);
	if(isNull(m1) || isNull(m2)) {
		return false;
	}
	if(!isNumber(m1) || !isNumber(m2)) {
		return false;
	}
	if(m1 == 0 || m2 == 0) {
		return false;
	}
	return true;
}

function focusInput(form) {
	if(isNull(form.username.value)) {
		form.username.focus();
	}
	else {
		form.password.focus();
	}
}

function writeFlashObject(objectID, movie, width, height, bgcolor) {
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+width+"' height='"+height+"'");
	if(objectID) {
		document.write(" id='"+objectID+"' name='"+objectID+"'");
	}
	document.writeln(">");
	document.writeln("   <param name='movie' value='"+movie+"'>");
	document.writeln("   <param name='quality' value='high'>");
	document.writeln("   <param name='bgcolor' value='"+(bgcolor ? bgcolor : "#FFFFFF")+"'>");
	document.writeln("   <embed src='"+movie+"' quality='high' bgcolor='"+(bgcolor ? bgcolor : "#FFFFFF")+"' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>");
	document.writeln("</object>");
}



